﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using GuRenFang.Common;

namespace GuRenFang.Controllers
{
   public class ErrorHanderFilter : System.Web.Mvc.HandleErrorAttribute
    {
       public override void OnException(ExceptionContext filterContext)
       {
           if (filterContext == null)
               return;
           var exception = filterContext.Exception ?? new Exception("No further information exists.");
           if (filterContext.RequestContext.HttpContext.Request.Url != null)
           {
               LoggerManager.Instance.DefaultLogger.Error(filterContext.RequestContext.HttpContext.Request.Url.ToString(), exception);
           }
           else
           {
               LoggerManager.Instance.DefaultLogger.Error(exception.Message);
           }
           //filterContext.ExceptionHandled = true;
           base.OnException(filterContext);
       }
    }
}
